package com.fz.controller;

import com.fz.service.PermissionService;
import com.fz.service.RoleResService;
import com.fz.vo.ResultVo;
import com.fz.vo.RoleResVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 存储角色与权限对应关系 前端控制器
 * </p>
 *
 * @author hyr
 * @since 2025-06-18
 */
@RestController
@RequestMapping("/roleRes")
public class RoleResController {
    @Resource
    PermissionService permissionService;
    @Resource
    RoleResService roleResService;
    @GetMapping("/getRes")
    ResultVo<RoleResVo> getRes(Long roleId){
        return ResultVo.success(new RoleResVo(permissionService.getList(),roleResService.getByRoleId(roleId)));
    }
    @PostMapping("/save")
    ResultVo<Boolean> save(Long roleId, Long[] menuIds, Long[] btnIds){
        return ResultVo.success(roleResService.save(roleId, menuIds, btnIds));
    }
}
